answer = 0
for x in range(1,1001):
	answer = answer + x**x
print(str(answer)[-10:])